package edu.cmu.vlis.datamining.SimilarityFeatures;

import org.jgrapht.alg.NeighborIndex;

import edu.cmu.vlis.datamining.core.Edge;
import edu.cmu.vlis.datamining.core.Feature;
import edu.cmu.vlis.datamining.core.IFeatureCalculator;
import edu.cmu.vlis.datamining.core.Vertex;

public class PreferentialAttachment implements IFeatureCalculator{

    private NeighborIndex<Vertex, Edge> nIndex;
    private int featureId;
    
    public PreferentialAttachment(NeighborIndex<Vertex, Edge> neighborIndex) {
        
        this.nIndex = neighborIndex;
        this.featureId = 4;
    }
    public Feature compute(Vertex a, Vertex b) {

       return  new Feature(this.featureId, (float)(this.nIndex.neighborsOf(a).size() * this.nIndex.neighborsOf(b).size()));
    }

}
